NPM 镜像源配置

1# 当前用户
2npm config set registry https://registry.npmmirror.com
3
4# ROOT
5sudo npm config set registry https://registry.npmmirror.com

发生的问题

错误消息

1npm ERR! Cannot read property 'insert' of undefined

这是因为配置了错误的地址,下载失败导致的。

解决办法

1# 当前用户
2npm cache clear --force
3npm config set registry https://registry.npmmirror.com
4
5# ROOT
6sudo npm cache clear --force
7sudo npm config set registry https://registry.npmmirror.com